-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add badge for NuGet download count, again #945
Conversation
The v2 API returned XML even though we asked for JSON. MyGet is still not working. Part of #655.
Switched from SearchAutocompleteService to SearchQueryService as this service also provides download counts.
1089f74
to
afbe203
Compare
This looks great! I have a couple minor comments and I'll run some tests when you're done addressing them. Thanks for clearing up this long-standing issue. Would you be interested in helping maintain shields? Modernization could be good… We've started using lexical scope, template strings, and arrow functions in new code. (You're welcome to use those here if you'd like.) Promises could improve error handling and reduce some of the callback boilerplate. It would be a big change, so it's something we need to plan and execute gradually. I try to avoid changing code solely for the sake of updating the style, though sometimes it's necessary. We're being conservative with |
server.js
Outdated
try { | ||
// Official NuGet server uses "totalDownloads" whereas MyGet uses | ||
// "totaldownloads" (lowercase D). Ugh. | ||
var downloads = nugetData.totalDownloads || nugetData.totaldownloads; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if there are zero downloads? Would 'totalDownloads' in nugetData ? nugetData.totalDownloads : nugetData.totaldownloads
be safer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nugetData.totalDownloads || nugetData.totaldownloads || 0
is probably fine.
In theory, everything should be using totalDownloads
and totaldownloads
should not exist. Certainly there'll never be a feed in which both totalDownloads
and totaldownloads
exist, as many JSON parsers are not case-sensitive or have an option to disable case-sensitivity. I suspect the lowercase totaldownloads
is simply a bug in MyGet.
try.html
Outdated
</tr> | ||
<tr><th> MyGet tenant: </th> | ||
<td><img src='/dotnet.myget/dotnet-coreclr/dt/Microsoft.DotNet.CoreCLR.svg' alt=''/></td> | ||
<td><code>https://img.shields.iodotnet.myget/dotnet-coreclr/dt/Microsoft.DotNet.CoreCLR.svg</code></td> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That link is missing a /
.
server.js
Outdated
if (filteredVersions.length > 0) { | ||
versions = filteredVersions; | ||
} | ||
data = data.data && data.data[0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you make this a more explicit check that it's an array, and with the expected length?
Thanks for the review! The issues you mentioned should be fixed now.
Yeah, sure! I could try to help out 😃
I posted some ideas in #948 if you're interested!
We could always go through the pull requests and close out all the stale ones (where the author hasn't responded). Then go through all the current ones and see what could be merged easily. I think it's fine to tell people that code is in the process of being cleaned up and they'll need to rebase, particularly if they've got a large PR :)
This is a great focus. In my team at work, we recently had a "quality week" where we spent the whole week improving unit/integration/functional test coverage of our app, and also improving type safety (we use Flow for typechecking all our newer JavaScript). Tests will be great as we'll feel more confident with the changes being made. 👍 |
Sounds like fun!
Total aside: it seems to me that TypeScript has gotten an edge recently. Why did FB choose Flow?
This is true. However, I tend to look at unmerged contributions as an unmined asset. There are some features in there I want to include – #409, #611, #774, #786 to name a few – and if those contributors don't respond, I'll fix them up myself. With the tests, that process should be fast and pleasant. I think it's realistic. 12 days ago there were 55 open pull requests and now there are 42, so I'm hopeful we can work through it by mid-May. I've also not wanted to merge things too fast, because I don't want to be too far ahead if things break on deploy, and also because I've only been onboard a month or so. |
Oh, good catch! I forgot to change the label on the badge to say "downloads". I can do that tonight 😃
I remember initially, Flow did a better job at inferring types from untyped code than TypeScript did. These days, both Flow and TypeScript seem good - I don't know if one has any advantages over the other. My team use Flow mainly because Flow is built by Facebook, so we can work closely with the Flow team if we encounter any issues. The app I work on (Ads - Power Editor) was actually the first app to ever use Flow in production. We have one of the largest JS apps at Facebook so it was a good test bed 😃 |
I can't find the examples in the Downloads section for NuGet now, time to bring them back? ;) |
I'm just being eager to try this, but I still can't get this to work: https://img.shields.io/nuget/dt/Moq.svg |
This change hasn't been deployed yet.
Sent from my phone.
…On Apr 21, 2017 6:58 PM, "Daniel Cazzulino" ***@***.***> wrote:
I'm just being eager to try this, but I still can't get this to work:
https://img.shields.io/nuget/dt/Moq.svg
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#945 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAFnHaboh6DGfTMK09Y0dGElApSrm9xXks5ryV6ygaJpZM4M_4pa>
.
|
gentle nudge 👍 |
Not forgotten. We're waiting along with you. |
This has been deployed. 🚀 |
NuGet download badges giveth, and NuGet download badges taketh away.
Now they're back, in
pogV3 form.I switched the NuGet badges from the
SearchAutocompleteService
to theSearchQueryService
. The SearchQueryService returns download counts in addition to version numbers.This works for both NuGet and MyGet:
I also verified that the version number badges still work as expected:
I tried to keep the style as close to the original code as possible, although this code could do with some modernization (like using promises rather than callbacks) at some point. I'm happy to help with that 😃
Closes #678